home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / FireMan.swf / scripts / frame_1055 / PlaceObject2_362_31 / CLIPACTIONRECORD onClipEvent(enterFrame).as next >
Text File  |  2008-09-12  |  3KB  |  130 lines

  1. onClipEvent(enterFrame){
  2.    function doexplode()
  3.    {
  4.       myColor.setTransform(myColorNormal);
  5.       this.gotoAndStop("death");
  6.    }
  7.    function dorespawn()
  8.    {
  9.       currentdamage = 0;
  10.       hitted = false;
  11.       flashing = false;
  12.       timerdamage = 0;
  13.       death = false;
  14.       this.gotoAndStop("standing");
  15.       idle = true;
  16.       attack = preattack = attacking = false;
  17.       _X = xi;
  18.       _Y = _root.mapa._y - yi;
  19.       shoot = new Sound();
  20.       shoot.attachSound("barrelshoot");
  21.    }
  22.    function drawframe()
  23.    {
  24.       if(idle)
  25.       {
  26.          this.gotoAndStop("standing");
  27.       }
  28.       if(attacking)
  29.       {
  30.          this.gotoAndStop("attack");
  31.       }
  32.    }
  33.    xi -= heroe.scrollspeed;
  34.    _X = _X - heroe.scrollspeed;
  35.    _Y = _root.mapa._y - yi;
  36.    _visible = false;
  37.    hitable = this.hitTest(_parent.mascara);
  38.    if(hitable)
  39.    {
  40.       _visible = true;
  41.       if(this.sprite.hotzone.hitTest(heroe.sprite.hotzone))
  42.       {
  43.          heroe.damage = 3;
  44.          heroe.hitted = true;
  45.       }
  46.       if(this.sprite.hotzone.hitTest(_parent.shoot1) && hitable)
  47.       {
  48.          hitted = true;
  49.          _root.shoot1.impact = true;
  50.          _root.hitted.start();
  51.       }
  52.       if(timerdamage == 0 && hitted)
  53.       {
  54.          timerdamage = FLASHTIME;
  55.          currentdamage += DAMAGE;
  56.       }
  57.       if(timerdamage > 0)
  58.       {
  59.          flashing = true;
  60.          timerdamage % 3 != 0 ? myColor.setTransform(myColorNormal) : myColor.setTransform(myColorTransform);
  61.          timerdamage--;
  62.       }
  63.       if(flashing && timerdamage == 0)
  64.       {
  65.          flashing = false;
  66.          myColor.setTransform(myColorNormal);
  67.          hitted = false;
  68.       }
  69.       if(currentdamage >= MAXDAMAGE)
  70.       {
  71.          myColor.setTransform(myColorTransform);
  72.          death = true;
  73.          delete shoot;
  74.       }
  75.       if(death)
  76.       {
  77.          _root.shoot1.impact = false;
  78.          doexplode();
  79.       }
  80.    }
  81.    if(!death)
  82.    {
  83.       if(idle)
  84.       {
  85.          if(Math.abs(heroe._x - _X) <= 140 && Math.abs(heroe._y - _Y) <= 220)
  86.          {
  87.             attack = attacking = false;
  88.             idle = false;
  89.             preattack = true;
  90.             timer = DELAY;
  91.          }
  92.       }
  93.       if(preattack)
  94.       {
  95.          timer--;
  96.          if(!timer)
  97.          {
  98.             preattack = false;
  99.             attack = true;
  100.          }
  101.       }
  102.       if(attack && !attacking)
  103.       {
  104.          attacking = true;
  105.          this.attachMovie("bullet","b1",1);
  106.          this.attachMovie("bullet","b2",2);
  107.          shoot.start();
  108.          b1.control.dx = SPEED;
  109.          b1._x = -12;
  110.          b1._y = -14;
  111.          b2.control.dx = -1 * SPEED;
  112.          b2._x = 12;
  113.          b2._y = -14;
  114.       }
  115.       if(attacking)
  116.       {
  117.          if(!b1.hitTest(_root.mascara) && !b2.hitTest(_root.mascara))
  118.          {
  119.             attacking = attack = preattack = false;
  120.             idle = true;
  121.          }
  122.       }
  123.       drawframe();
  124.    }
  125.    else if(!_root.mascara.hitTest(xi,yi))
  126.    {
  127.       dorespawn();
  128.    }
  129. }
  130.